/**
 * In me the tiger sniffs the rose.
 *
 * @Author:徐家政
 * @Date:2019-04-19 22:05
 */
package com.shiyu.demo.controller;

import com.shiyu.demo.entity.About;
import com.shiyu.demo.entity.CommunityPost;
import com.shiyu.demo.service.WritePostService;
import com.shiyu.demo.util.R;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@CrossOrigin
public class WritePostController {
    @Resource
    private WritePostService writePostService;
    @RequestMapping("/community/getwriteinfo")
    public R getUserImg(Integer userid){

       String userImg= writePostService.getUserImg(userid);
       List<About>aboutList=writePostService.getAbout();
       return R.ok().put("userImg",userImg).put("aboutList",aboutList);
    }
    @RequestMapping("/community/addpost")
    public R addPost(Integer userid, String posttext, String postname, Integer aboutid){
        int i= writePostService.addPost(userid, posttext, postname, aboutid);
        if (i==0){
            return R.error("添加失败");
        }
        return R.ok();
    }
}
